#define _CRT_SECURE_NO_WARNINGS 1
//牛客 KY11 二叉树遍历

#include <stdio.h>
#include <stdlib.h>
typedef char BTDataType;
typedef struct BTreeNode
{
	BTDataType data;
	struct BTreeNode* left;
	struct BTreeNode* right;
}BTNode;

BTNode* BuyBTNode(BTDataType x)
{
	BTNode* node = (BTNode*)malloc(sizeof(BTNode));
	if (NULL == node)
	{
		perror("malloc fail:");
		return NULL;
	}

	node->data = x;
	node->left = node->right = NULL;
	return node;
}
BTNode* CreateBTree(BTDataType* a, int* pi)
{
	if ('#' == a[*pi])
	{
		(*pi)++;
		return NULL;
	}


	BTNode* root = BuyBTNode(a[*pi]);
	(*pi)++;
	root->left = CreateBTree(a, pi);
	root->right = CreateBTree(a, pi);

	return root;
}
void InOrder(BTNode* root)
{
	if (NULL == root)
		return;

	InOrder(root->left);
	printf("%c ", root->data);
	InOrder(root->right);
}
int main()
{
	char a[100];
	scanf("%s", a);
	int i = 0;
	BTNode* root = CreateBTree(a, &i);
	InOrder(root);

	return 0;
}